<template>
	<view class="bill" :data-theme="themeStyle">
		<mescroll-uni ref="mescroll" @getData="getData" class="member-point" :size="8">
			<block slot="list">
				<view class="balances" v-if="accountList.length" v-for="item in accountList" :key="item.id">
					<image v-if="item.type == 'order'" :src="$util.img('upload/uniapp/fenxiao/bill/jiesuan.png')" mode="widthFix"></image>
					<image v-else :src="$util.img('upload/uniapp/fenxiao/bill/withdraw.png')" mode="widthFix"></image>
					<view class="balances-info">
						<text>{{ item.type_name }}</text>
						<text>账单编号: {{ item.account_no }}</text>
						<text>{{ $util.timeStampTurnTime(item.create_time) }}</text>
					</view>
					<view class="balances-num">
						<text :class="item.money>0? 'ns-text-color':''">{{item.money>0? '+'+item.money : item.money }}</text>
					</view>
				</view>
				
				<view v-if="!accountList.length && showEmpty" class="cart-empty">
					<ns-empty text="您当前没有账单信息哦" :isIndex="!1"></ns-empty>
				</view>
			</block>
			<loading-cover ref="loadingCover"></loading-cover>
		</mescroll-uni>
		<ns-show-toast></ns-show-toast>
	</view>
</template>

<script>
import globalConfig from '@/common/js/golbalConfig.js'
import nsShowToast from '@/components/ns-show-toast/ns-show-toast.vue'
export default {
	data() {
		return {
			accountList: {},
			showEmpty:false
		};
	},
	components: {
		nsShowToast
	},
	onLoad() {},
	onShow() {
		// 刷新多语言
		this.$langConfig.refresh();
	},
	mixins:[globalConfig],
	methods: {
		getData(mescroll) {
			if (mescroll.num == 1) {
				this.accountList = [];
			}
			this.showEmpty=false;
			this.$api.sendRequest({
				url: '/fenxiao/api/account/page',
				data: {
					page: mescroll.num,
					page_size: mescroll.size,
					is_settlement: this.selectId
				},
				success: res => {
					this.showEmpty=true;
					let newArr = [];
					let msg = res.message;
					if (res.code == 0 && res.data && res.data.list) {
						newArr = res.data.list;
					} else {
						this.$util.showToast({ title: msg });
					}
					mescroll.endSuccess(newArr.length);
					//设置列表数据
					if (mescroll.num == 1) this.accountList = []; //如果是第一页需手动制空列表
					this.accountList = this.accountList.concat(newArr); //追加新数据
					if (this.$refs.loadingCover) this.$refs.loadingCover.hide();
				},
				fail: res => {
					this.showEmpty=true;
					mescroll.endErr();
					if (this.$refs.loadingCover) this.$refs.loadingCover.hide();
				}
			});
		}
	}
};
</script>

<style lang="scss">
/deep/ .fixed{position: relative;top:0}
/deep/ .empty{margin-top: 0 !important;}
.cart-empty{position:relative;top: 50%;padding-top: 154px !important;}

.balances {
		width: 702rpx;
		border-radius: 10rpx;
		margin: 0 auto;
		padding: 27rpx 27rpx;
		box-sizing: border-box;
		display: flex;
		align-items: flex-start;
		background: #fff;
		margin-bottom: 18rpx;
		margin-top: 18rpx;
		image {
			width: 54rpx;
			height: 54rpx;
			border-radius: 50%;
		}
		.balances-info {
			flex: 1;
			margin-left: 16rpx;
			display: flex;
			flex-direction: column;
			text {
				line-height: 1;
				&:last-child {
					font-size: $ns-font-size-lg;
				}
				&:nth-child(2) {
					margin-top: 18rpx;
					font-size: $ns-font-size-x-sm;
					color: #A9A9A9;
				}
				&:nth-child(3) {
					font-size: $ns-font-size-x-sm;
					margin-top: 19rpx;
					color: #A9A9A9;
				}
			}
		}
		.balances-num {
			text {
				line-height: 1;
				font-size: $ns-font-size-x-lg;
				color: #000;
			}
		}
	
	}
</style>
